<div class="body-wrap" xmlns:ext="http://www.extjs.com"><div class="top-tools"><a class="inner-link" href="#Ext.data.XmlReader-props"><img src="images/default/s.gif" class="item-icon icon-prop">Properties</a>&#13;<a class="inner-link" href="#Ext.data.XmlReader-methods"><img src="images/default/s.gif" class="item-icon icon-method">Methods</a>&#13;<a class="inner-link" href="#Ext.data.XmlReader-events"><img src="images/default/s.gif" class="item-icon icon-event">Events</a>&#13;<a class="inner-link" href="#Ext.data.XmlReader-configs"><img src="images/default/s.gif" class="item-icon icon-config">Config Options</a>&#13;<a class="bookmark" href="../docs/?class=Ext.data.XmlReader"><img src="images/default/s.gif" class="item-icon icon-fav">Direct Link</a>&#13;</div><div class="inheritance res-block"><pre class="res-block-inner"><a href="output/Ext.data.Reader.html" ext:member="" ext:cls="Ext.data.Reader">Reader</a>
  <img src="resources/elbow-end.gif">XmlReader</pre></div><h1>Class <a href="source/XmlReader.html#cls-Ext.data.XmlReader">Ext.data.XmlReader</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.data</td></tr><tr><td class="label">Defined In:</td><td class="hd-info"><a href="source/XmlReader.html#cls-Ext.data.XmlReader">XmlReader.js</a></td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/XmlReader.html#cls-Ext.data.XmlReader">XmlReader</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info"><a href="output/Ext.data.Reader.html" ext:cls="Ext.data.Reader" ext:member="">Reader</a></td></tr></table><div class="description"><p>The XML Reader is used by a Proxy to read a server response that is sent back in XML format. This usually
happens as a result of loading a Store - for example we might create something like this:</p>
<pre><code>Ext.regModel(<em>'User'</em>, {
    fields: [<em>'id'</em>, <em>'name'</em>, <em>'email'</em>]
});

<b>var</b> store = <b>new</b> Ext.data.Store({
    model: <em>'User'</em>,
    proxy: {
        type: <em>'ajax'</em>,
        url : <em>'users.xml'</em>,
        reader: {
            type: <em>'xml'</em>,
            record: <em>'user'</em>
        }
    }
});</code></pre>
<p>The example above creates a 'User' model. Models are explained in the <a href="output/Ext.data.Model.html" ext:cls="Ext.data.Model">Model</a> docs if you're
not already familiar with them.</p>
<p>We created the simplest type of XML Reader possible by simply telling our <a href="output/Ext.data.Store.html" ext:cls="Ext.data.Store">Store</a>'s 
<a href="output/Ext.data.Proxy.html" ext:cls="Ext.data.Proxy">Proxy</a> that we want a XML Reader. The Store automatically passes the configured model to the
Store, so it is as if we passed this instead:
<pre><code>reader: {
    type : <em>'xml'</em>,
    model: <em>'User'</em>,
    record: <em>'user'</em>
}</code></pre>
<p>The reader we set up is ready to read data from our server - at the moment it will accept a response like this:</p>
<pre><code>&lt;?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?&gt;
&lt;user&gt;
    &lt;id&gt;1&lt;/id&gt;
    &lt;name&gt;Ed Spencer&lt;/name&gt;
    &lt;email&gt;ed@sencha.com&lt;/email&gt;
&lt;/user&gt;
&lt;user&gt;
    &lt;id&gt;2&lt;/id&gt;
    &lt;name&gt;Abe Elias&lt;/name&gt;
    &lt;email&gt;abe@sencha.com&lt;/email&gt;
&lt;/user&gt;</code></pre>
<p>The XML Reader uses the configured <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-record" ext:member="record" ext:cls="Ext.data.XmlReader">record</a> option to pull out the data for each record - in this case we
set record to 'user', so each &lt;user&gt; above will be converted into a User model.</p>
<p><u>Reading other XML formats</u></p>
<p>If you already have your XML format defined and it doesn't look quite like what we have above, you can usually
pass XmlReader a couple of configuration options to make it parse your format. For example, we can use the 
<a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-root" ext:member="root" ext:cls="Ext.data.XmlReader">root</a> configuration to parse data that comes back like this:</p>
<pre><code>&lt;?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?&gt;
&lt;users&gt;
    &lt;user&gt;
        &lt;id&gt;1&lt;/id&gt;
        &lt;name&gt;Ed Spencer&lt;/name&gt;
        &lt;email&gt;ed@sencha.com&lt;/email&gt;
    &lt;/user&gt;
    &lt;user&gt;
        &lt;id&gt;2&lt;/id&gt;
        &lt;name&gt;Abe Elias&lt;/name&gt;
        &lt;email&gt;abe@sencha.com&lt;/email&gt;
    &lt;/user&gt;
&lt;/users&gt;</code></pre>
<p>To parse this we just pass in a <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-root" ext:member="root" ext:cls="Ext.data.XmlReader">root</a> configuration that matches the 'users' above:</p>
<pre><code>reader: {
    type  : <em>'xml'</em>,
    root  : <em>'users'</em>,
    record: <em>'user'</em>
}</code></pre>
<p>Note that XmlReader doesn't care whether your <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-root" ext:member="root" ext:cls="Ext.data.XmlReader">root</a> and <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-record" ext:member="record" ext:cls="Ext.data.XmlReader">record</a> elements are nested deep inside
a larger structure, so a response like this will still work:
<pre><code>&lt;?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?&gt;
&lt;deeply&gt;
    &lt;nested&gt;
        &lt;xml&gt;
            &lt;users&gt;
                &lt;user&gt;
                    &lt;id&gt;1&lt;/id&gt;
                    &lt;name&gt;Ed Spencer&lt;/name&gt;
                    &lt;email&gt;ed@sencha.com&lt;/email&gt;
                &lt;/user&gt;
                &lt;user&gt;
                    &lt;id&gt;2&lt;/id&gt;
                    &lt;name&gt;Abe Elias&lt;/name&gt;
                    &lt;email&gt;abe@sencha.com&lt;/email&gt;
                &lt;/user&gt;
            &lt;/users&gt;
        &lt;/xml&gt;
    &lt;/nested&gt;
&lt;/deeply&gt;</code></pre>
<p><u>Response metadata</u></p>
<p>The server can return additional data in its response, such as the <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-totalProperty" ext:member="totalProperty" ext:cls="Ext.data.XmlReader">total number of records</a> 
and the <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-successProperty" ext:member="successProperty" ext:cls="Ext.data.XmlReader">success status of the response</a>. These are typically included in the XML response
like this:</p>
<pre><code>&lt;?xml version=<em>"1.0"</em> encoding=<em>"UTF-8"</em>?&gt;
&lt;total&gt;100&lt;/total&gt;
&lt;success&gt;true&lt;/success&gt;
&lt;users&gt;
    &lt;user&gt;
        &lt;id&gt;1&lt;/id&gt;
        &lt;name&gt;Ed Spencer&lt;/name&gt;
        &lt;email&gt;ed@sencha.com&lt;/email&gt;
    &lt;/user&gt;
    &lt;user&gt;
        &lt;id&gt;2&lt;/id&gt;
        &lt;name&gt;Abe Elias&lt;/name&gt;
        &lt;email&gt;abe@sencha.com&lt;/email&gt;
    &lt;/user&gt;
&lt;/users&gt;</code></pre>
<p>If these properties are present in the XML response they can be parsed out by the XmlReader and used by the
Store that loaded it. We can set up the names of these properties by specifying a final pair of configuration 
options:</p>
<pre><code>reader: {
    type: <em>'xml'</em>,
    root: <em>'users'</em>,
    totalProperty  : <em>'total'</em>,
    successProperty: <em>'success'</em>
}</code></pre>
<p>These final options are not necessary to make the Reader work, but can be useful when the server needs to report
an error or if it needs to indicate that there is a lot of data available of which only a subset is currently being
returned.</p>
<p><u>Response format</u></p>
<p><b>Note:</b> in order for the browser to parse a returned XML document, the Content-Type header in the HTTP 
response must be set to "text/xml" or "application/xml". This is very important - the XmlReader will not
work correctly otherwise.</p></div><div class="hr"></div><a id="Ext.data.XmlReader-configs"></a><h2>Config Options</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Config Options</th><th class="msource-header">Defined By</th></tr><tr class="config-row  "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-id"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-id">id</a></b> : String<div class="mdesc">DEPRECATED - this will be removed in Ext JS 5.0. Please use idProperty instead</div></td><td class="msource">XmlReader</td></tr><tr class="config-row  "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-idPath"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-idPath">idPath</a></b> : String<div class="mdesc">DEPRECATED - this will be removed in Ext JS 5.0. Please use idProperty instead</div></td><td class="msource">XmlReader</td></tr><tr class="config-row  inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-idProperty"></a><b><a href="source/Reader.html#cfg-Ext.data.Reader-idProperty">idProperty</a></b> : String<div class="mdesc">Name of the property within a row object
that contains a record identifier value.  Defaults to <tt>id</tt></div></td><td class="msource"><a href="output/Ext.data.Reader.html#idProperty" ext:member="#idProperty" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="config-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-implicitIncludes"></a><b><a href="source/Reader.html#cfg-Ext.data.Reader-implicitIncludes">implicitIncludes</a></b> : Boolean<div class="mdesc"><div class="short">True to automatically parse models nested within other models in a response
object. See the Ext.data.Reader intro doc...</div><div class="long">True to automatically parse models nested within other models in a response
object. See the Ext.data.Reader intro docs for full explanation. Defaults to true.</div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#implicitIncludes" ext:member="#implicitIncludes" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="config-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-record"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-record">record</a></b> : String<div class="mdesc"><div class="short">The DomQuery path to the repeated element which contains record information.
This is an alias for the root config opt...</div><div class="long">The DomQuery path to the repeated element which contains record information.
<b>This is an alias for the <a href="output/Ext.data.XmlReader.html#Ext.data.XmlReader-root" ext:member="root" ext:cls="Ext.data.XmlReader">root</a> config option.</b></div></div></td><td class="msource">XmlReader</td></tr><tr class="config-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-root"></a><b><a href="source/Reader.html#cfg-Ext.data.Reader-root">root</a></b> : String<div class="mdesc"><div class="short">Required.  The name of the property
which contains the Array of row objects.  Defaults to undefined.
An exception wil...</div><div class="long"><b>Required</b>.  The name of the property
which contains the Array of row objects.  Defaults to <tt>undefined</tt>.
An exception will be thrown if the root property is undefined. The data
packet value for this property should be an empty array to clear the data
or show no data.</div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#root" ext:member="#root" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="config-row  "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-success"></a><b><a href="source/XmlReader.html#cfg-Ext.data.XmlReader-success">success</a></b> : String<div class="mdesc">DEPRECATED - this will be removed in Ext JS 5.0. Please use successProperty instead</div></td><td class="msource">XmlReader</td></tr><tr class="config-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-successProperty"></a><b><a href="source/Reader.html#cfg-Ext.data.Reader-successProperty">successProperty</a></b> : String<div class="mdesc"><div class="short">Name of the property from which to
retrieve the success attribute. Defaults to success.  See
Ext.data.DataProxy.excep...</div><div class="long">Name of the property from which to
retrieve the success attribute. Defaults to <tt>success</tt>.  See
<a href="output/Ext.data.DataProxy.html" ext:cls="Ext.data.DataProxy">Ext.data.DataProxy</a>.<a href="output/Ext.data.DataProxy.html#Ext.data.DataProxy-exception" ext:member="exception" ext:cls="Ext.data.DataProxy">exception</a>
for additional information.</div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#successProperty" ext:member="#successProperty" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="config-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-totalProperty"></a><b><a href="source/Reader.html#cfg-Ext.data.Reader-totalProperty">totalProperty</a></b> : String<div class="mdesc"><div class="short">Name of the property from which to
retrieve the total number of records in the dataset. This is only needed
if the wh...</div><div class="long">Name of the property from which to
retrieve the total number of records in the dataset. This is only needed
if the whole dataset is not passed in one go, but is being paged from
the remote server.  Defaults to <tt>total</tt>.</div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#totalProperty" ext:member="#totalProperty" ext:cls="Ext.data.Reader">Reader</a></td></tr></tbody></table><a id="Ext.data.XmlReader-props"></a><h2>Public Properties</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Property</th><th class="msource-header">Defined By</th></tr><tr class="property-row  inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-rawData"></a><b><a href="source/Reader.html#prop-Ext.data.Reader-rawData">rawData</a></b> : Mixed<div class="mdesc">The raw data object that was last passed to readRecords. Stored for further processing if needed</div></td><td class="msource"><a href="output/Ext.data.Reader.html#rawData" ext:member="#rawData" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="property-row  "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-xmlData"></a><b><a href="source/XmlReader.html#prop-Ext.data.XmlReader-xmlData">xmlData</a></b> : Object<div class="mdesc">DEPRECATED - will be removed in Ext JS 5.0. This is just a copy of this.rawData - use that instead</div></td><td class="msource">XmlReader</td></tr></tbody></table><a id="Ext.data.XmlReader-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-getData"></a><b><a href="source/XmlReader.html#method-Ext.data.XmlReader-getData">getData</a></b>(&nbsp;<code>Object&nbsp;data</code>&nbsp;)
    :
                                        Object<div class="mdesc"><div class="short">Normalizes the data object</div><div class="long">Normalizes the data object<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>data</code> : Object<div class="sub-desc">The raw data object</div></li></ul><strong>Returns:</strong><ul><li><code>Object</code><div class="sub-desc">Returns the documentElement property of the data object if present, or the same object if not</div></li></ul></div></div></div></td><td class="msource">XmlReader</td></tr><tr class="method-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-getResponseData"></a><b><a href="source/Reader.html#method-Ext.data.Reader-getResponseData">getResponseData</a></b>(&nbsp;<code>Object&nbsp;response</code>&nbsp;)
    :
                                        Object<div class="mdesc"><div class="short">Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemen...</div><div class="long">Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemented by each subclass<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>response</code> : Object<div class="sub-desc">The responce object</div></li></ul><strong>Returns:</strong><ul><li><code>Object</code><div class="sub-desc">The useful data from the response</div></li></ul></div></div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#getResponseData" ext:member="#getResponseData" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="method-row expandable inherited"><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.Reader-read"></a><b><a href="source/Reader.html#method-Ext.data.Reader-read">read</a></b>(&nbsp;<code>Object&nbsp;response</code>&nbsp;)
    :
                                        Ext.data.ResultSet<div class="mdesc"><div class="short">Reads the given response object. This method normalizes the different types of response object that may be passed
to ...</div><div class="long">Reads the given response object. This method normalizes the different types of response object that may be passed
to it, before handing off the reading of records to the <a href="output/readRecords.html" ext:cls="readRecords">readRecords</a> function.<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>response</code> : Object<div class="sub-desc">The response object. This may be either an XMLHttpRequest object or a plain JS object</div></li></ul><strong>Returns:</strong><ul><li><code>Ext.data.ResultSet</code><div class="sub-desc">The parsed ResultSet object</div></li></ul></div></div></div></td><td class="msource"><a href="output/Ext.data.Reader.html#read" ext:member="#read" ext:cls="Ext.data.Reader">Reader</a></td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi">&nbsp;</a></td><td class="sig"><a id="Ext.data.XmlReader-readRecords"></a><b><a href="source/XmlReader.html#method-Ext.data.XmlReader-readRecords">readRecords</a></b>(&nbsp;<code>Object&nbsp;doc</code>&nbsp;)
    :
                                        Ext.data.ResultSet<div class="mdesc"><div class="short">Parses an XML document and returns a ResultSet containing the model instances</div><div class="long">Parses an XML document and returns a ResultSet containing the model instances<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>doc</code> : Object<div class="sub-desc">Parsed XML document</div></li></ul><strong>Returns:</strong><ul><li><code>Ext.data.ResultSet</code><div class="sub-desc">The parsed result set</div></li></ul></div></div></div></td><td class="msource">XmlReader</td></tr></tbody></table><a id="Ext.data.XmlReader-events"></a><h2>Public Events</h2><div class="no-members">This class has no public events.</div></div>